package com.tcy.bigevent.validation;

import com.tcy.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

//public class StateValidation implements ConstraintValidator<给哪个注解提供校验规则, 校验的数据类型> {
public class StateValidation implements ConstraintValidator<State, String> {
    /**
     * 校验逻辑
     * @param value object to validate
     * @param constraintValidatorContext
     * @return 如果返回false,则校验不通过；否则通过
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        if(value == null) return false;
        else return value.equals("已发布") || value.equals("草稿");
    }
}
